using com.byt.suce.db.dao;
using System;
using System.Data;
using System.Data.Common;
using com.byt.webcore;
using System.Collections.Generic;
using MYLSOFT.JsonSimple;
using System.Data.SqlClient;


namespace com.byt.suce.db.mapper {

    public class PkgMant : AbstractDataAccessObject , IPkgMant {

        public PkgMant() {
        }

        public PkgMant.ActGetlistParam actGetlist(Connection conn, Dictionary<string, string> map) {
            PkgMant.ActGetlistParam param = newActGetlistParam(map);
            actGetlist(conn, param);
            return param;
        }

        public PkgMant.ActGetlistParam actGetlist(Connection conn, JSONObject json) {
            PkgMant.ActGetlistParam param = newActGetlistParam(json);
            actGetlist(conn, param);
            return param;
        }

        public PkgMant.ActGetlistParam actGetlist(Connection conn) {
            PkgMant.ActGetlistParam param = newActGetlistParam();
            actGetlist(conn, param);
            return param;
        }

        public void actGetlist(Connection conn, PkgMant.ActGetlistParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].MAN_act_getlist";
            DbParameter par = null;
            // cur_out
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_out";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgMant.ClasificacionSearchParam clasificacionSearch(Connection conn, Dictionary<string, string> map) {
            PkgMant.ClasificacionSearchParam param = newClasificacionSearchParam(map);
            clasificacionSearch(conn, param);
            return param;
        }

        public PkgMant.ClasificacionSearchParam clasificacionSearch(Connection conn, JSONObject json) {
            PkgMant.ClasificacionSearchParam param = newClasificacionSearchParam(json);
            clasificacionSearch(conn, param);
            return param;
        }

        public PkgMant.ClasificacionSearchParam clasificacionSearch(Connection conn) {
            PkgMant.ClasificacionSearchParam param = newClasificacionSearchParam();
            clasificacionSearch(conn, param);
            return param;
        }

        public void clasificacionSearch(Connection conn, PkgMant.ClasificacionSearchParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].MAN_clasificacion_search";
            DbParameter par = null;
            // nombclasificacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombclasificacion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 200;
            if (string.IsNullOrEmpty(param.Nombclasificacion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombclasificacion;
            // cur_out
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_out";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgMant.ReportesGetListParam reportesGetList(Connection conn, Dictionary<string, string> map)
        {
            PkgMant.ReportesGetListParam param = newReportesGetList(map);
            reportesGetList(conn, param);
            return param;
        }

        public PkgMant.ReportesGetListParam reportesGetList(Connection conn, JSONObject json)
        {
            PkgMant.ReportesGetListParam param = newReportesGetList(json);
            reportesGetList(conn, param);
            return param;
        }

        public PkgMant.ReportesGetListParam reportesGetList(Connection conn)
        {
            PkgMant.ReportesGetListParam param = newReportesGetList();
            reportesGetList(conn, param);
            return param;
        }

        public void reportesGetList(Connection conn, PkgMant.ReportesGetListParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "sp_listar_informes";
            DbParameter par = null;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@curOut";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgMant.JerarquiaGetListParam jerarquiaGetList(Connection conn, Dictionary<string, string> map) 
        {
            PkgMant.JerarquiaGetListParam param = newJerarquiaGetList(map);
            jerarquiaGetList(conn, param);
            return param;
        }

        public PkgMant.JerarquiaGetListParam jerarquiaGetList(Connection conn, JSONObject json)
        {
            PkgMant.JerarquiaGetListParam param = newJerarquiaGetList(json);
            jerarquiaGetList(conn, param);
            return param;
        }

        public PkgMant.JerarquiaGetListParam jerarquiaGetList(Connection conn)
        {
            PkgMant.JerarquiaGetListParam param = newJerarquiaGetList();
            jerarquiaGetList(conn, param);
            return param;
        }

        public void jerarquiaGetList(Connection conn, PkgMant.JerarquiaGetListParam param) 
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "sp_jerarquia";
            DbParameter par = null;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@solicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Solicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Solicitud;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@version";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Version == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Version;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@parent";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@children";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.Parent = (DbDataReader)ds.Tables[0].CreateDataReader();
            param.Child = (DbDataReader)ds.Tables[1].CreateDataReader();

            
        }

        public PkgMant.ChecklistGetListParam checklistGetList(Connection conn, Dictionary<string, string> map)
        {
            PkgMant.ChecklistGetListParam param = newChecklistGetListParam(map);
            checklistGetList(conn, param);
            return param;
        }

        public PkgMant.ChecklistGetListParam checklistGetList(Connection conn, JSONObject json)
        {
            PkgMant.ChecklistGetListParam param = newChecklistGetListParam(json);
            checklistGetList(conn, param);
            return param;
        }

        public PkgMant.ChecklistGetListParam checklistGetList(Connection conn)
        {
            PkgMant.ChecklistGetListParam param = newChecklistGetListParam();
            checklistGetList(conn, param);
            return param;
        }

        public void AdicionalChecklist(Connection conn, PkgMant.ChecklistGetListParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "sp_insertTask";
            DbParameter par = null;

            //idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;

            //idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;

            //descripcion            
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@descripcion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 4000;
            par.Value = DBNull.Value;
            /*
            par.Value=DBNull.Value;
            if (string.IsNullOrEmpty(param.Descripcion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Descripcion;
            */
            //estado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 500;
            par.Value = DBNull.Value;
            /*
            if (string.IsNullOrEmpty(param.Estado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estado;
            */
            //modo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@modo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            par.Value = "C";
            /*
            if (string.IsNullOrEmpty(param.Modo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Modo;
            */
            //curOut
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@curOut";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public void checklistGetList(Connection conn, PkgMant.ChecklistGetListParam param)
        {
            if (param.Datos == null)
            {
                AdicionalChecklist(conn, param);
            }
            else
            {
                JSONObject json = new JSONObject();                
                json = (JSONObject)JSONValue.Parse(param.Datos);
                JSONArray ja;
                DbCommand cmd;                
                DbParameter par=null;
                //cmd = conn.CreateCommand();

                ja=(JSONArray)json["checked"]; //actualizando los checks de todo el grid
                if (ja != null)
                {
                    foreach (JSONObject rcheck in ja)
                    {
                        cmd = conn.CreateCommand();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "sp_insertTask";
                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idsolicitud";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idsolicitud == null)
                            par.Value = DBNull.Value;
                        else
                            par.Value = param.Idsolicitud;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idversion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idversion == null)
                            par.Value = DBNull.Value;
                        else
                            par.Value = param.Idversion;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@descripcion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 4000;
                        par.Value = DBNull.Value;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@estado";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        if (string.IsNullOrEmpty(rcheck["valorcheck"].ToString()))
                            par.Value = DBNull.Value;
                        else
                            par.Value = rcheck["valorcheck"].ToString();

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@modo";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        par.Value = "V";

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@item";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (rcheck["item"].ToString() == "0")
                            par.Value = DBNull.Value;
                        else
                            par.Value = int.Parse(rcheck["item"].ToString());

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@curOut";
                        par.Direction = ParameterDirection.InputOutput;
                        par.DbType = DbType.Object;
                        par.Value = DBNull.Value;

                        cmd.ExecuteNonQuery();

                    }
                }

                ja=(JSONArray)json["actualizados"];
                if (ja != null)
                {
                    foreach (JSONObject actual in ja)
                    {
                        cmd = conn.CreateCommand();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "sp_insertTask";
                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idsolicitud";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idsolicitud == null)
                            par.Value = DBNull.Value;
                        else
                            par.Value = param.Idsolicitud;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idversion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idversion == null)
                            par.Value = DBNull.Value;
                        else
                            par.Value = param.Idversion;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@descripcion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 4000;
                        if (string.IsNullOrEmpty(actual["descripcion"].ToString()))
                            par.Value = DBNull.Value;
                        else
                            par.Value = actual["descripcion"].ToString();

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@estado";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        if (string.IsNullOrEmpty(actual["valorcheck"].ToString()))
                            par.Value = DBNull.Value;
                        else
                            par.Value = actual["valorcheck"].ToString();

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@modo";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        par.Value = "U";

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@item";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (actual["item"].ToString() == "0")
                            par.Value = DBNull.Value;
                        else
                            par.Value = int.Parse(actual["item"].ToString());

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@curOut";
                        par.Direction = ParameterDirection.InputOutput;
                        par.DbType = DbType.Object;
                        par.Value = DBNull.Value;

                        cmd.ExecuteNonQuery();

                    }
                }

                ja=(JSONArray)json["eliminados"];
                if (ja != null)
                {
                    foreach (JSONObject eliminados in ja)
                    {
                        cmd = conn.CreateCommand();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "sp_insertTask";
                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idsolicitud";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idsolicitud == null)
                            par.Value = DBNull.Value;
                        else
                            par.Value = param.Idsolicitud;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idversion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idversion == null)
                            par.Value = DBNull.Value;
                        else
                            par.Value = param.Idversion;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@descripcion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 4000;
                        par.Value = DBNull.Value;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@estado";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        par.Value = DBNull.Value;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@item";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (eliminados["item"].ToString() == "0")
                            par.Value = DBNull.Value;
                        else
                            par.Value = int.Parse(eliminados["item"].ToString());

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@modo";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        par.Value = "E";

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@curOut";
                        par.Direction = ParameterDirection.InputOutput;
                        par.DbType = DbType.Object;
                        par.Value = DBNull.Value;

                        cmd.ExecuteNonQuery();

                    }
                }
                
                ja = (JSONArray)json["nuevos"];
                if (ja != null)
                {
                    foreach (JSONObject nuevo in ja)
                    {
                        cmd = conn.CreateCommand();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "sp_insertTask";
                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idsolicitud";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idsolicitud == null)
                            par.Value = DBNull.Value;
                        else
                            par.Value = param.Idsolicitud;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@idversion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.Int32;
                        if (param.Idversion == null)                        
                            par.Value = DBNull.Value;                        
                        else
                            par.Value = param.Idversion;

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@descripcion";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 4000;
                        if (string.IsNullOrEmpty(nuevo["descripcion"].ToString()))
                            par.Value=DBNull.Value;
                        else
                            par.Value=nuevo["descripcion"].ToString();

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@estado";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        if (string.IsNullOrEmpty(nuevo["valorcheck"].ToString()))
                            par.Value = DBNull.Value;
                        else
                            par.Value = nuevo["valorcheck"].ToString();

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@modo";
                        par.Direction = ParameterDirection.Input;
                        par.DbType = DbType.String;
                        par.Size = 1;
                        par.Value = "I";

                        par = cmd.CreateParameter();
                        cmd.Parameters.Add(par);
                        par.ParameterName = "@curOut";
                        par.Direction = ParameterDirection.InputOutput;
                        par.DbType = DbType.Object;
                        par.Value = DBNull.Value;

                        cmd.ExecuteNonQuery();

                    }
                }

                AdicionalChecklist(conn, param);

            }

        }

        public PkgMant.EvaluadoresGetListParam evaluadoresGetList(Connection conn, Dictionary<string, string> map)
        {
            PkgMant.EvaluadoresGetListParam param = newEvaluadoresGetListParam(map);
            evaluadoresGetList(conn, param);
            return param;
        }

        public PkgMant.EvaluadoresGetListParam evaluadoresGetList(Connection conn, JSONObject json)
        {
            PkgMant.EvaluadoresGetListParam param = newEvaluadoresGetListParam(json);
            evaluadoresGetList(conn, param);
            return param;
        }

        public PkgMant.EvaluadoresGetListParam evaluadoresGetList(Connection conn)
        {
            PkgMant.EvaluadoresGetListParam param = newEvaluadoresGetListParam();
            evaluadoresGetList(conn, param);
            return param;
        }

        public void evaluadoresGetList(Connection conn, PkgMant.EvaluadoresGetListParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "sp_listareval";
            DbParameter par = null;
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_out";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgMant.FormatoGetlistParam formatoGetlist(Connection conn, Dictionary<string, string> map) {
            PkgMant.FormatoGetlistParam param = newFormatoGetlistParam(map);
            formatoGetlist(conn, param);
            return param;
        }

        public PkgMant.FormatoGetlistParam formatoGetlist(Connection conn, JSONObject json) {
            PkgMant.FormatoGetlistParam param = newFormatoGetlistParam(json);
            formatoGetlist(conn, param);
            return param;
        }

        public PkgMant.FormatoGetlistParam formatoGetlist(Connection conn) {
            PkgMant.FormatoGetlistParam param = newFormatoGetlistParam();
            formatoGetlist(conn, param);
            return param;
        }

        public void formatoGetlist(Connection conn, PkgMant.FormatoGetlistParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].MAN_formato_getlist";
            DbParameter par = null;
            // cur_out
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_out";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgMant.UitGetbyidParam uitGetbyid(Connection conn, Dictionary<string, string> map) {
            PkgMant.UitGetbyidParam param = newUitGetbyidParam(map);
            uitGetbyid(conn, param);
            return param;
        }

        public PkgMant.UitGetbyidParam uitGetbyid(Connection conn, JSONObject json) {
            PkgMant.UitGetbyidParam param = newUitGetbyidParam(json);
            uitGetbyid(conn, param);
            return param;
        }

        public PkgMant.UitGetbyidParam uitGetbyid(Connection conn) {
            PkgMant.UitGetbyidParam param = newUitGetbyidParam();
            uitGetbyid(conn, param);
            return param;
        }

        public void uitGetbyid(Connection conn, PkgMant.UitGetbyidParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].MAN_uit_getbyid";
            DbParameter par = null;
            // idparametro
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idparametro";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idparametro == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idparametro;
            // cur_out
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_out";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgMant.UitGetlistParam uitGetlist(Connection conn, Dictionary<string, string> map) {
            PkgMant.UitGetlistParam param = newUitGetlistParam(map);
            uitGetlist(conn, param);
            return param;
        }

        public PkgMant.UitGetlistParam uitGetlist(Connection conn, JSONObject json) {
            PkgMant.UitGetlistParam param = newUitGetlistParam(json);
            uitGetlist(conn, param);
            return param;
        }

        public PkgMant.UitGetlistParam uitGetlist(Connection conn) {
            PkgMant.UitGetlistParam param = newUitGetlistParam();
            uitGetlist(conn, param);
            return param;
        }

        public void uitGetlist(Connection conn, PkgMant.UitGetlistParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].MAN_uit_getlist";
            DbParameter par = null;
            // cur_out
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_out";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgMant.UitUpdateParam uitUpdate(Connection conn, Dictionary<string, string> map) {
            PkgMant.UitUpdateParam param = newUitUpdateParam(map);
            uitUpdate(conn, param);
            return param;
        }

        public PkgMant.UitUpdateParam uitUpdate(Connection conn, JSONObject json) {
            PkgMant.UitUpdateParam param = newUitUpdateParam(json);
            uitUpdate(conn, param);
            return param;
        }

        public PkgMant.UitUpdateParam uitUpdate(Connection conn) {
            PkgMant.UitUpdateParam param = newUitUpdateParam();
            uitUpdate(conn, param);
            return param;
        }

        public void uitUpdate(Connection conn, PkgMant.UitUpdateParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].MAN_uit_update";
            DbParameter par = null;
            // idparametro
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idparametro";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idparametro == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idparametro;
            // valoparametro
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@valoparametro";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Valoparametro))
                par.Value = DBNull.Value;
            else
                par.Value = param.Valoparametro;
            cmd.ExecuteNonQuery();
        }

        public PkgMant.ActGetlistParam newActGetlistParam() {
            return new ActGetlistParam();
        }

        public PkgMant.ActGetlistParam newActGetlistParam(Dictionary<string, string> map) {
            return new ActGetlistParam(map);
        }

        public PkgMant.ActGetlistParam newActGetlistParam(JSONObject json) {
            return new ActGetlistParam(json);
        }

        public PkgMant.ClasificacionSearchParam newClasificacionSearchParam() {
            return new ClasificacionSearchParam();
        }

        public PkgMant.ClasificacionSearchParam newClasificacionSearchParam(Dictionary<string, string> map) {
            return new ClasificacionSearchParam(map);
        }

        public PkgMant.ClasificacionSearchParam newClasificacionSearchParam(JSONObject json) {
            return new ClasificacionSearchParam(json);
        }

        public PkgMant.ReportesGetListParam newReportesGetList()
        {
            return new ReportesGetListParam();
        }

        public PkgMant.ReportesGetListParam newReportesGetList(Dictionary<string, string> map)
        {
            return new ReportesGetListParam(map);
        }

        public PkgMant.ReportesGetListParam newReportesGetList(JSONObject json)
        {
            return new ReportesGetListParam(json);
        }

        public PkgMant.JerarquiaGetListParam newJerarquiaGetList() 
        {
            return new JerarquiaGetListParam();
        }

        public PkgMant.JerarquiaGetListParam newJerarquiaGetList(Dictionary<string, string> map)
        {
            return new JerarquiaGetListParam(map);
        }

        public PkgMant.JerarquiaGetListParam newJerarquiaGetList(JSONObject json)
        {
            return new JerarquiaGetListParam(json);
        }

        public PkgMant.ChecklistGetListParam newChecklistGetListParam() {
            return new ChecklistGetListParam();
        }

        public PkgMant.ChecklistGetListParam newChecklistGetListParam(Dictionary<string, string> map)
        {
            return new ChecklistGetListParam(map);
        }

        public PkgMant.ChecklistGetListParam newChecklistGetListParam(JSONObject json)
        {
            return new ChecklistGetListParam(json);
        }

        public PkgMant.EvaluadoresGetListParam newEvaluadoresGetListParam() {
            return new EvaluadoresGetListParam();
        }

        public PkgMant.EvaluadoresGetListParam newEvaluadoresGetListParam(Dictionary<string, string> map)
        {
            return new EvaluadoresGetListParam(map);
        }

        public PkgMant.EvaluadoresGetListParam newEvaluadoresGetListParam(JSONObject json)
        {
            return new EvaluadoresGetListParam(json);
        }


        public PkgMant.FormatoGetlistParam newFormatoGetlistParam() {
            return new FormatoGetlistParam();
        }

        public PkgMant.FormatoGetlistParam newFormatoGetlistParam(Dictionary<string, string> map) {
            return new FormatoGetlistParam(map);
        }

        public PkgMant.FormatoGetlistParam newFormatoGetlistParam(JSONObject json) {
            return new FormatoGetlistParam(json);
        }

        public PkgMant.UitGetbyidParam newUitGetbyidParam() {
            return new UitGetbyidParam();
        }

        public PkgMant.UitGetbyidParam newUitGetbyidParam(Dictionary<string, string> map) {
            return new UitGetbyidParam(map);
        }

        public PkgMant.UitGetbyidParam newUitGetbyidParam(JSONObject json) {
            return new UitGetbyidParam(json);
        }

        public PkgMant.UitGetlistParam newUitGetlistParam() {
            return new UitGetlistParam();
        }

        public PkgMant.UitGetlistParam newUitGetlistParam(Dictionary<string, string> map) {
            return new UitGetlistParam(map);
        }

        public PkgMant.UitGetlistParam newUitGetlistParam(JSONObject json) {
            return new UitGetlistParam(json);
        }

        public PkgMant.UitUpdateParam newUitUpdateParam() {
            return new UitUpdateParam();
        }

        public PkgMant.UitUpdateParam newUitUpdateParam(Dictionary<string, string> map) {
            return new UitUpdateParam(map);
        }

        public PkgMant.UitUpdateParam newUitUpdateParam(JSONObject json) {
            return new UitUpdateParam(json);
        }

        public class ActGetlistParam {

            private DbDataReader curOut;

            public ActGetlistParam() {
            }

            public ActGetlistParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public ActGetlistParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public DbDataReader CurOut {
                get { return curOut; }
                set { this.curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class ClasificacionSearchParam {

            private string nombclasificacion;
            private DbDataReader curOut;

            public ClasificacionSearchParam() {
            }

            public ClasificacionSearchParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public ClasificacionSearchParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public string Nombclasificacion {
                get { return nombclasificacion; }
                set { this.nombclasificacion = value; }
            }

            public DbDataReader CurOut {
                get { return curOut; }
                set { this.curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class ReportesGetListParam {
            private string nroreporte;
            private string formato;
            private string nrosuce;
            private int? idsolicitud;
            private int? idversion;
            private DbDataReader curOut;

            public ReportesGetListParam() { }

            public ReportesGetListParam(Dictionary<string, string> map) 
            {
                ResourceManager.populateDtoFromMap(this,map);       
            }

            public ReportesGetListParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public string Nroreporte
            {
                get { return nroreporte; }
                set { nroreporte = value; }
            }
            public string Formato
            {
                get { return formato; }
                set { formato = value; }
            }
            public string Nrosuce
            {
                get { return nrosuce; }
                set { nrosuce = value; }
            }
            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { idsolicitud = value; }
            }
            public int? Idversion
            {
                get { return idversion; }
                set { idversion = value; }
            }

            public DbDataReader CurOut
            {
                get { return curOut; }
                set { curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }
        }

        public class JerarquiaGetListParam {
            private string formato;
            private int? solicitud;            
            private int? version;            
            private int? flujo;
            private string orden;            
            private string suce;
            private string actividad;            
            private string nombactividad;
            private DbDataReader parent;
            private DbDataReader child;

            public JerarquiaGetListParam() { }

            public JerarquiaGetListParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public JerarquiaGetListParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this,json);
            }

            public string Formato
            {
                get { return formato; }
                set { formato = value; }
            }
            public int? Solicitud
            {
                get { return solicitud; }
                set { solicitud = value; }
            }
            public int? Version
            {
                get { return version; }
                set { version = value; }
            }
            public int? Flujo
            {
                get { return flujo; }
                set { flujo = value; }
            }
            public string Orden
            {
                get { return orden; }
                set { orden = value; }
            }
            public string Suce
            {
                get { return suce; }
                set { suce = value; }
            }
            public string Actividad
            {
                get { return actividad; }
                set { actividad = value; }
            }
            public string Nombactividad
            {
                get { return nombactividad; }
                set { nombactividad = value; }
            }
            public DbDataReader Parent
            {
                get { return parent; }
                set { parent = value; }
            }
            public DbDataReader Child
            {
                get { return child; }
                set { child = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class ChecklistGetListParam {
            private int? item;
            private string descripcion;
            private string estado;
            private DateTime? fecha;
            private string modo;
            private int? idsolicitud;
            private int? idversion;            
            private DbDataReader curOut;
            private string datos;

            public string Datos
            {
                get { return datos; }
                set { datos = value; }
            }


            public ChecklistGetListParam() { }

            public ChecklistGetListParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public ChecklistGetListParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Item
            {
                get { return item; }
                set { item = value; }
            }
            public string Descripcion
            {
                get { return descripcion; }
                set { descripcion = value; }
            }
            public string Estado
            {
                get { return estado; }
                set { estado = value; }
            }
            public DateTime? Fecha
            {
                get { return fecha; }
                set { fecha = value; }
            }
            public string Modo
            {
                get { return modo; }
                set { modo = value; }
            }
            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { idsolicitud = value; }
            }
            public int? Idversion
            {
                get { return idversion; }
                set { idversion = value; }
            }
            public DbDataReader CurOut
            {
                get { return curOut; }
                set { curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }
        }

        public class EvaluadoresGetListParam {
            private DbDataReader curOut;

            public EvaluadoresGetListParam() { }

            public EvaluadoresGetListParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);                    
            }

            public EvaluadoresGetListParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public DbDataReader CurOut
            {
                get { return curOut; }
                set { this.curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class FormatoGetlistParam {

            private DbDataReader curOut;

            public FormatoGetlistParam() {
            }

            public FormatoGetlistParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public FormatoGetlistParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public DbDataReader CurOut {
                get { return curOut; }
                set { this.curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class UitGetbyidParam {

            private int? idparametro;
            private DbDataReader curOut;

            public UitGetbyidParam() {
            }

            public UitGetbyidParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public UitGetbyidParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idparametro {
                get { return idparametro; }
                set { this.idparametro = value; }
            }

            public DbDataReader CurOut {
                get { return curOut; }
                set { this.curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class UitGetlistParam {

            private DbDataReader curOut;

            public UitGetlistParam() {
            }

            public UitGetlistParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public UitGetlistParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public DbDataReader CurOut {
                get { return curOut; }
                set { this.curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class UitUpdateParam {

            private int? idparametro;
            private string valoparametro;

            public UitUpdateParam() {
            }

            public UitUpdateParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public UitUpdateParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idparametro {
                get { return idparametro; }
                set { this.idparametro = value; }
            }

            public string Valoparametro {
                get { return valoparametro; }
                set { this.valoparametro = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

    }
}
